cmake_minimum_required(VERSION 3.16)

project(webrtc-demo)

include_directories(${PROJECT_SOURCE_DIR}/webrtc-audio-processing-0.3.1)

set(PATH ${PROJECT_SOURCE_DIR}/webrtc-audio-processing-0.3.1/webrtc)

add_definitions(-DWEBRTC_POSIX -DWEBRTC_LINUX -DWEBRTC_AUDIO_PROCESSING_ONLY_BUILD -DWEBRTC_NS_FLOAT)

set(SRCS
    ${PATH}/common_types.cc
    
    ${PATH}/base/event.cc
    ${PATH}/base/platform_thread.cc
    ${PATH}/base/stringutils.cc
    ${PATH}/base/thread_checker_impl.cc
    ${PATH}/base/criticalsection.cc
    ${PATH}/base/checks.cc
    ${PATH}/base/platform_file.cc

    ${PATH}/common_audio/wav_file.cc
    # ${PATH}/common_audio/fir_filter_neon.cc
    ${PATH}/common_audio/vad/vad_filterbank.c
    ${PATH}/common_audio/vad/vad_sp.c
    ${PATH}/common_audio/vad/vad_gmm.c
    ${PATH}/common_audio/vad/webrtc_vad.c
    ${PATH}/common_audio/vad/vad.cc
    ${PATH}/common_audio/vad/vad_core.c
    ${PATH}/common_audio/fft4g.c
    ${PATH}/common_audio/lapped_transform.cc
    ${PATH}/common_audio/ring_buffer.c
    ${PATH}/common_audio/fir_filter_sse.cc
    ${PATH}/common_audio/window_generator.cc
    ${PATH}/common_audio/audio_converter.cc
    ${PATH}/common_audio/real_fourier_ooura.cc
    ${PATH}/common_audio/real_fourier.cc
    ${PATH}/common_audio/channel_buffer.cc
    ${PATH}/common_audio/fir_filter.cc
    ${PATH}/common_audio/blocker.cc
    ${PATH}/common_audio/wav_header.cc
    ${PATH}/common_audio/sparse_fir_filter.cc
    ${PATH}/common_audio/audio_ring_buffer.cc
    ${PATH}/common_audio/audio_util.cc
    
    ${PATH}/common_audio/resampler/push_sinc_resampler.cc
    ${PATH}/common_audio/resampler/sinc_resampler.cc
    ${PATH}/common_audio/resampler/sinc_resampler_sse.cc
    ${PATH}/common_audio/resampler/sinusoidal_linear_chirp_source.cc
    ${PATH}/common_audio/resampler/resampler.cc
    # ${PATH}/common_audio/resampler/sinc_resampler_neon.cc
    ${PATH}/common_audio/resampler/push_resampler.cc

    
    ${PATH}/common_audio/signal_processing/sqrt_of_one_minus_x_squared.c
    # ${PATH}/common_audio/signal_processing/min_max_operations_neon.c
    ${PATH}/common_audio/signal_processing/real_fft.c
    ${PATH}/common_audio/signal_processing/randomization_functions.c
    ${PATH}/common_audio/signal_processing/spl_init.c
    ${PATH}/common_audio/signal_processing/complex_bit_reverse.c
    # ${PATH}/common_audio/signal_processing/vector_scaling_operations_mips.c
    ${PATH}/common_audio/signal_processing/resample_by_2.c
    ${PATH}/common_audio/signal_processing/dot_product_with_scale.c
    # ${PATH}/common_audio/signal_processing/complex_bit_reverse_mips.c
    ${PATH}/common_audio/signal_processing/spl_sqrt_floor.c
    ${PATH}/common_audio/signal_processing/resample.c
    ${PATH}/common_audio/signal_processing/lpc_to_refl_coef.c
    ${PATH}/common_audio/signal_processing/cross_correlation.c
    ${PATH}/common_audio/signal_processing/resample_48khz.c
    ${PATH}/common_audio/signal_processing/auto_corr_to_refl_coef.c
    ${PATH}/common_audio/signal_processing/get_scaling_square.c
    ${PATH}/common_audio/signal_processing/auto_correlation.c
    ${PATH}/common_audio/signal_processing/splitting_filter.c
    # ${PATH}/common_audio/signal_processing/cross_correlation_mips.c
    ${PATH}/common_audio/signal_processing/filter_ar.c
    # ${PATH}/common_audio/signal_processing/filter_ar_fast_q12_mips.c
    # ${PATH}/common_audio/signal_processing/spl_sqrt_floor_mips.c
    ${PATH}/common_audio/signal_processing/vector_scaling_operations.c
    ${PATH}/common_audio/signal_processing/min_max_operations.c
    # ${PATH}/common_audio/signal_processing/downsample_fast_mips.c
    # ${PATH}/common_audio/signal_processing/complex_fft_mips.c
    ${PATH}/common_audio/signal_processing/get_hanning_window.c
    ${PATH}/common_audio/signal_processing/refl_coef_to_lpc.c
    ${PATH}/common_audio/signal_processing/levinson_durbin.c
    ${PATH}/common_audio/signal_processing/ilbc_specific_functions.c
    ${PATH}/common_audio/signal_processing/spl_sqrt.c
    ${PATH}/common_audio/signal_processing/division_operations.c
    ${PATH}/common_audio/signal_processing/complex_fft.c
    ${PATH}/common_audio/signal_processing/filter_ma_fast_q12.c
    ${PATH}/common_audio/signal_processing/resample_fractional.c
    # ${PATH}/common_audio/signal_processing/cross_correlation_neon.c
    ${PATH}/common_audio/signal_processing/copy_set_operations.c
    ${PATH}/common_audio/signal_processing/filter_ar_fast_q12.c
    ${PATH}/common_audio/signal_processing/resample_by_2_internal.c
    ${PATH}/common_audio/signal_processing/downsample_fast.c
    ${PATH}/common_audio/signal_processing/energy.c
    # ${PATH}/common_audio/signal_processing/min_max_operations_mips.c
    # ${PATH}/common_audio/signal_processing/downsample_fast_neon.c
    # ${PATH}/common_audio/signal_processing/resample_by_2_mips.c
    
    ${PATH}/modules/audio_coding/codecs/isac/main/source/filterbanks.c
    ${PATH}/modules/audio_coding/codecs/isac/main/source/lpc_tables.c
    ${PATH}/modules/audio_coding/codecs/isac/main/source/filter_functions.c
    ${PATH}/modules/audio_coding/codecs/isac/main/source/encode_lpc_swb.c
    ${PATH}/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb16_tables.c
    ${PATH}/modules/audio_coding/codecs/isac/main/source/pitch_filter.c
    ${PATH}/modules/audio_coding/codecs/isac/main/source/pitch_lag_tables.c
    ${PATH}/modules/audio_coding/codecs/isac/main/source/lpc_analysis.c
    ${PATH}/modules/audio_coding/codecs/isac/main/source/lpc_gain_swb_tables.c
    ${PATH}/modules/audio_coding/codecs/isac/main/source/lpc_shape_swb12_tables.c
    ${PATH}/modules/audio_coding/codecs/isac/main/source/arith_routines_hist.c
    ${PATH}/modules/audio_coding/codecs/isac/main/source/pitch_gain_tables.c
    ${PATH}/modules/audio_coding/codecs/isac/main/source/spectrum_ar_model_tables.c
    ${PATH}/modules/audio_coding/codecs/isac/main/source/filterbank_tables.c
    ${PATH}/modules/audio_coding/codecs/isac/main/source/arith_routines.c
    ${PATH}/modules/audio_coding/codecs/isac/main/source/arith_routines_logist.c
    ${PATH}/modules/audio_coding/codecs/isac/main/source/pitch_estimator.c
    ${PATH}/modules/audio_coding/codecs/isac/main/source/entropy_coding.c
    ${PATH}/modules/audio_coding/codecs/isac/main/source/intialize.c

    ${PATH}/modules/audio_processing/aecm/aecm_core_c.c
    # ${PATH}/modules/audio_processing/aecm/aecm_core_neon.c
    # ${PATH}/modules/audio_processing/aecm/aecm_core_mips.c
    ${PATH}/modules/audio_processing/aecm/echo_control_mobile.c
    ${PATH}/modules/audio_processing/aecm/aecm_core.c
    ${PATH}/modules/audio_processing/aec/aec_rdft_sse2.c
    ${PATH}/modules/audio_processing/aec/aec_rdft.c
    # ${PATH}/modules/audio_processing/aec/aec_core_mips.c
    # ${PATH}/modules/audio_processing/aec/aec_core_neon.c
    ${PATH}/modules/audio_processing/aec/echo_cancellation.c
    # ${PATH}/modules/audio_processing/aec/aec_rdft_neon.c
    ${PATH}/modules/audio_processing/aec/aec_core_sse2.c
    ${PATH}/modules/audio_processing/aec/aec_resampler.c
    ${PATH}/modules/audio_processing/aec/aec_core.c
    ${PATH}/modules/audio_processing/intelligibility/intelligibility_enhancer.cc
    ${PATH}/modules/audio_processing/intelligibility/intelligibility_utils.cc
    ${PATH}/modules/audio_processing/gain_control_impl.cc
    ${PATH}/modules/audio_processing/utility/delay_estimator.c
    ${PATH}/modules/audio_processing/utility/delay_estimator_wrapper.c
    ${PATH}/modules/audio_processing/vad/standalone_vad.cc
    ${PATH}/modules/audio_processing/vad/pitch_based_vad.cc
    ${PATH}/modules/audio_processing/vad/pitch_internal.cc
    ${PATH}/modules/audio_processing/vad/vad_circular_buffer.cc
    ${PATH}/modules/audio_processing/vad/pole_zero_filter.cc
    ${PATH}/modules/audio_processing/vad/voice_activity_detector.cc
    ${PATH}/modules/audio_processing/vad/vad_audio_proc.cc
    ${PATH}/modules/audio_processing/vad/gmm.cc
    ${PATH}/modules/audio_processing/transient/transient_detector.cc
    ${PATH}/modules/audio_processing/transient/file_utils.cc
    ${PATH}/modules/audio_processing/transient/transient_suppressor.cc
    ${PATH}/modules/audio_processing/transient/wpd_tree.cc
    # ${PATH}/modules/audio_processing/transient/click_annotate.cc
    ${PATH}/modules/audio_processing/transient/wpd_node.cc
    ${PATH}/modules/audio_processing/transient/moving_moments.cc
    ${PATH}/modules/audio_processing/processing_component.cc
    ${PATH}/modules/audio_processing/rms_level.cc
    ${PATH}/modules/audio_processing/three_band_filter_bank.cc
    ${PATH}/modules/audio_processing/agc/utility.cc
    ${PATH}/modules/audio_processing/agc/legacy/digital_agc.c
    ${PATH}/modules/audio_processing/agc/legacy/analog_agc.c
    ${PATH}/modules/audio_processing/agc/histogram.cc
    ${PATH}/modules/audio_processing/agc/agc_manager_direct.cc
    ${PATH}/modules/audio_processing/agc/agc.cc
    ${PATH}/modules/audio_processing/voice_detection_impl.cc
    ${PATH}/modules/audio_processing/level_estimator_impl.cc
    ${PATH}/modules/audio_processing/audio_processing_impl.cc
    ${PATH}/modules/audio_processing/beamformer/covariance_matrix_generator.cc
    ${PATH}/modules/audio_processing/beamformer/array_util.cc
    ${PATH}/modules/audio_processing/beamformer/nonlinear_beamformer.cc
    # ${PATH}/modules/audio_processing/ns/nsx_core_neon.c
    ${PATH}/modules/audio_processing/ns/noise_suppression.c
    ${PATH}/modules/audio_processing/ns/nsx_core.c
    ${PATH}/modules/audio_processing/ns/ns_core.c
    ${PATH}/modules/audio_processing/ns/noise_suppression_x.c
    ${PATH}/modules/audio_processing/ns/nsx_core_c.c
    # ${PATH}/modules/audio_processing/ns/nsx_core_mips.c
    ${PATH}/modules/audio_processing/typing_detection.cc
    ${PATH}/modules/audio_processing/audio_buffer.cc
    ${PATH}/modules/audio_processing/noise_suppression_impl.cc
    ${PATH}/modules/audio_processing/echo_cancellation_impl.cc
    ${PATH}/modules/audio_processing/echo_control_mobile_impl.cc
    ${PATH}/modules/audio_processing/logging/aec_logging_file_handling.cc
    ${PATH}/modules/audio_processing/high_pass_filter_impl.cc
    ${PATH}/modules/audio_processing/splitting_filter.cc
    
    # ${PATH}/system_wrappers/source/event.cc
    # # ${PATH}/system_wrappers/source/critical_section_win.cc
    # ${PATH}/system_wrappers/source/critical_section.cc
    # # ${PATH}/system_wrappers/source/trace_win.cc
    # # ${PATH}/system_wrappers/source/event_timer_win.cc
    # ${PATH}/system_wrappers/source/logging.cc
    # ${PATH}/system_wrappers/source/metrics_default.cc
    # ${PATH}/system_wrappers/source/rw_lock_posix.cc
    # ${PATH}/system_wrappers/source/cpu_features.cc
    # ${PATH}/system_wrappers/source/file_impl.cc
    # ${PATH}/system_wrappers/source/event_timer_posix.cc
    # # ${PATH}/system_wrappers/source/condition_variable_native_win.cc
    # ${PATH}/system_wrappers/source/aligned_malloc.cc
    # ${PATH}/system_wrappers/source/rw_lock_generic.cc
    # ${PATH}/system_wrappers/source/thread.cc
    # # ${PATH}/system_wrappers/source/thread_win.cc
    # # ${PATH}/system_wrappers/source/condition_variable_event_win.cc
    # ${PATH}/system_wrappers/source/trace_posix.cc
    # ${PATH}/system_wrappers/source/thread_posix.cc
    # ${PATH}/system_wrappers/source/sleep.cc
    # # ${PATH}/system_wrappers/source/condition_variable.cc
    # ${PATH}/system_wrappers/source/trace_impl.cc
    # # ${PATH}/system_wrappers/source/rw_lock_win.cc
    # ${PATH}/system_wrappers/source/rw_lock.cc
    # ${PATH}/system_wrappers/source/critical_section_posix.cc 
    ${PATH}/system_wrappers/source/aligned_malloc.cc
    ${PATH}/system_wrappers/source/cpu_features.cc
    ${PATH}/system_wrappers/source/event.cc
    ${PATH}/system_wrappers/source/file_impl.cc
    ${PATH}/system_wrappers/source/critical_section.cc
    ${PATH}/system_wrappers/source/logging.cc
    ${PATH}/system_wrappers/source/metrics_default.cc
    ${PATH}/system_wrappers/source/rw_lock.cc
    ${PATH}/system_wrappers/source/sleep.cc
    ${PATH}/system_wrappers/source/thread.cc
    ${PATH}/system_wrappers/source/trace_impl.cc
    ${PATH}/system_wrappers/source/critical_section_posix.cc
    ${PATH}/system_wrappers/source/event_timer_posix.cc
    ${PATH}/system_wrappers/source/rw_lock_posix.cc
    ${PATH}/system_wrappers/source/thread_posix.cc
    ${PATH}/system_wrappers/source/trace_posix.cc

)

add_executable(beamformer ${PROJECT_SOURCE_DIR}/examples/beamformer_test.cc ${SRCS})
add_executable(aecm ${PROJECT_SOURCE_DIR}/examples/aecm_test.cc ${SRCS})
add_executable(aec ${PROJECT_SOURCE_DIR}/examples/aec_test.cc ${SRCS})